<template>
	<view>
		<view class="top">
			<view class="score">
				<text>
					当前积分
				</text>
				<view class="num">
					{{score}}
				</view>
			</view>
			<image src="@/static/staff/icon1.png" mode=""></image>
		</view>
		<view class="container">
			<view class="title">
				<image src="@/static/admin/icon/icon2.png" mode=""></image> 积分明细
			</view>
			<view class="list">
				<view class="col" v-for="item in list" :key="item.id">
					<view class="left">
						<image v-if="item.score>0" src="@/static/admin/icon/icon3.png" mode=""></image>
						<image v-else src="@/static/admin/icon/icon4.png" mode=""></image>
						<view class="text">
							<view class="time">
								<uni-dateformat :date="item.createtime*1000"></uni-dateformat>
							</view>
							{{item.memo}}
						</view>
					</view>
					<view class="right" :class="{'bonus':item.score>0}">
						<text v-if="item.score>0">+</text>
						{{item.score}}
						<image v-if="item.score<0" src="@/static/admin/icon/icon1.png" mode=""></image>
						<image v-else src="@/static/admin/icon/icon2.png" mode=""></image>
					</view>
				</view>
			</view>
		</view>
		<uni-load-more :status="status"></uni-load-more>
	</view>
</template>

<script>
	import tabbar from "@/components/tabbar_staff.vue"
	export default {
		components: {
			tabbar
		},
		data() {
			return {
				list: [],
				page: 1,
				status: "no-more",
				score: '',
				statusBarHeight: null,
				keywords: ''
			}
		},
		onLoad() {
			this.init()
			this.getInfo()
		},
		onPullDownRefresh() {
			this.init()
		},
		onReachBottom() {
			this.page++
			this.getList()
		},
		methods: {
			getInfo() {
				this.$post("/user/userinfo").then(res => {
					this.score = res.data.score
				})
			},
			init() {
				this.list = []
				this.page = 1
				this.getList()
			},
			getList() {
				this.status = "loading"
				this.$post("/user/score", {
					page: this.page,
					user_id: this.user_id
				}).then(res => {
					this.status = "no-more"
					uni.stopPullDownRefresh()
					this.list = this.list.concat(res.data.data)
				})
			},

		}
	}
</script>

<style lang="scss" scoped>
	.top {
		position: relative;
		color: #fff;
		height: 250rpx;
		background: #3670F6;
		display: flex;
		align-items: center;
		padding: 0 30rpx;

		.score {

			text {
				color: #D9E4FF;
				font-size: 26rpx;
			}

			.num {
				font-size: 48rpx;
				margin-top: 20rpx;
			}
		}

		image {
			position: absolute;
			width: 350rpx;
			height: 350rpx;
			right: -80rpx;
			top: 50%;
			transform: translateY(-50%);
		}
	}

	.container {
		padding: 20rpx 34rpx;
		position: relative;

		.title {
			display: flex;
			align-items: center;
			color: $main-color;
			font-size: 30rpx;
			border-bottom: 1rpx solid #eee;
			padding: 30rpx 0;

			image {
				width: 30rpx;
				height: 30rpx;
				margin-right: 20rpx;
			}
		}

		.list {
			.col {
				padding: 20rpx 0;
				border-bottom: 1rpx solid #eee;
				display: flex;
				align-items: center;
				justify-content: space-between;

				.left {
					display: flex;
					align-items: center;
					width: calc(100% - 160rpx);

					image {
						width: 76rpx;
						height: 76rpx;
					}

					.text {
						width: calc(100% - 76rpx);
						padding: 0 20rpx;
						font-size: 30rpx;

						.time {
							font-size: 24rpx;
							color: #7d7d7d;
							margin-bottom: 10rpx;
						}
					}
				}

				.right {
					max-width: 160rpx;
					color: #1BAFAA;
					font-size: 36rpx;
					text-align: right;

					&.bonus {
						color: #3670F6;
					}

					image {
						width: 30rpx;
						height: 30rpx;
						margin-left: 20rpx;
					}
				}
			}
		}
	}
</style>